{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 双指针\n",
    "- a [1,2,4,7,8,9]\n",
    "- b [1,3,5,7,8] "
   ]
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-10-25T12:11:35.120737Z",
     "start_time": "2024-10-25T12:11:35.112235Z"
    }
   },
   "source": [
    "local = [1,2,4,7,8,9]\n",
    "webdav = [1,3,5,7,8] \n",
    "i = 0\n",
    "j = 0\n",
    "localDiffWeb = []\n",
    "webDiffLocal = []\n",
    "while i< len(local) or j < len(webdav):\n",
    "    if i == len(local):\n",
    "        webDiffLocal.extend(webdav[j:])\n",
    "        break\n",
    "    if j == len(webdav):\n",
    "        localDiffWeb.extend(local[i:])\n",
    "        break\n",
    "    if local[i] == webdav[j]:\n",
    "        # 正常，可以进行其他参数比较\n",
    "        print(\"相同\",local[i],webdav[j])\n",
    "        i+=1\n",
    "        j+=1\n",
    "        continue\n",
    "    if local[i] < webdav[j]:\n",
    "        # local有，webdav没有\n",
    "        localDiffWeb.append(local[i])\n",
    "        i+=1\n",
    "        continue\n",
    "    if local[i] > webdav[j]:\n",
    "        # webdav有，local没有\n",
    "        webDiffLocal.append(webdav[j])\n",
    "        j+=1\n",
    "        continue\n",
    "\n",
    "print(localDiffWeb,webDiffLocal)"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "相同 1 1\n",
      "相同 7 7\n",
      "相同 8 8\n",
      "[2, 4, 9] [3, 5]\n"
     ]
    }
   ],
   "execution_count": 3
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": ""
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
